document.oncontextmenu = function(){
    return false;
}
document.ondragstart = function(){
    return false;
}

//鼠标点击效果
var text = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"];
var color = ['#ff0000', '#eb4310', '#f6941d', '#fbb417', '#ffff00', '#cdd541', '#99cc33', '#3f9337', '#219167', '#239676', '#24998d', '#1f9baa', '#0080ff', '#3366cc', '#333399', '#003366', '#800080', '#a1488e', '#c71585', '#bd2158', '#eec142', '#FEEE6D'];
window.onload = function () {
    document.querySelector("body").onclick = function () {
        var e = event || window.event;
        var textNum = Math.floor(Math.random() * text.length);
        var colorNUm = Math.floor(Math.random() * color.length);
        var x = e.pageX;
        var y = e.pageY;
        var flag = document.createElement("span");
        flag.append("" + text[textNum] + "");
        flag.style.zIndex = 999999;
        flag.style.fontWeight = "bold";
        flag.style.position = "absolute";
        flag.style.top = y - 20 + "px";
        flag.style.left = x - 15 + "px";
        flag.style.color = color[colorNUm];
        document.querySelector("body").append(flag);
        var timer;
        var i = 180, m = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], n = 0;
        cancelAnimationFrame(timer);
        timer = requestAnimationFrame(function fn() {
            if (i > 0) {
                i--;
                flag.style.opacity = i / 180;
                flag.style.top = y - 15 - (180 - i) + 'px';
                flag.style.left = x - 15 + m[n] + "px";
                if (i % 2 == 0)
                    n++;
                timer = requestAnimationFrame(fn);
                if (n > m.length) {
                    n = 0
                }
            }
            else {
                cancelAnimationFrame(timer);
                flag.remove();
            }
        });


    }
}
function displayOn(){
    setTimeout(function(){
            $(".chatPageShell").fadeIn("slow");
            $("body").css("overflow","hidden");
        },1000)
}
//页面滚动
var pageTo = function (num) {   //页面滚动
    let x = 0;
    let home=document.getElementById("homePage")
    const speed = 100;  //动画速度
    let position=num*(home.clientHeight);  //目标距离
    function step() {
        x++;
        if (x < speed) {
            if (x == speed - 1) {
                window.scrollTo(0, position+2);
                    displayOn();
            } else {
                window.scrollTo({
                    top: easeOutBounce(x / speed) * position
                })
                requestAnimationFrame(step);
            }
        }
    };
    step();
};



function addScript(url){
	var script = document.createElement('script');
	script.setAttribute('type','text/javascript');
	script.setAttribute('src',url);
	document.getElementsByTagName('head')[0].appendChild(script);
}
function homeCreateWindow(){
    setTimeout(function(){
                var  $clickWindow=$("<div class='clickWindow'></div>");
    let clickWindow2 = $(`
    <div class='windowFrist'>
    <div class='windowText'>
        <p>按一下世界毁灭什么的因该不会发生吧!<span>vw(ﾟДﾟ)w</span></p>
    </div>
    <div class='windowModel'>
        <p>要不要再按一下?</p>
        <div class='windowBtn'>
            <button id='windowBtn1'>好的</button>
            <button id='windowBtn2'>不要!</button>
        </div>
    </div>
</div>`)
        $("#homePage").append($clickWindow);
        $clickWindow.append(clickWindow2);
        addScript("./js/clickwindow.js");
    },500)
}
let clicks= 0;
